<?php

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

Route::match(['GET', 'PUT'], '/login', 'AuthController@login');

//支付成功回调
Route::match(['GET', 'POST'], '/notify/wechat', 'PayNotifyController@wechat')->name('notify.wechat');
Route::match(['GET', 'POST'], '/notify/test', 'PayNotifyController@test')->name('notify.test');

Route::group(['middleware' => 'api.auth'], function () {
    //region 用户中心
    //用户信息
    Route::put('/token/check', 'AuthController@checkToken');
    Route::get('/user/info', 'AuthController@getUserInfo');
    //endregion

    //激活发布者身份
    Route::put('/publisher/active', 'PublisherController@active');

    //用户订单列表
    Route::get('/user/order', 'UserOrderController@index');
    //用户订单详情
    Route::get('/user/order/{id}', 'UserOrderController@show');
    //用户订单申诉
    Route::post('/user/order/{id}/appeal', 'UserOrderController@appeal');
    //用户订单详情
    Route::post('/user/order/{id}/message', 'UserOrderController@leaveMessage');

    //首页-信息列表
    Route::get('/item', 'ItemController@index');
    //信息详情
    Route::get('/item/{id}', 'ItemController@show');

    Route::post('/pay/wechat', 'OrderController@wechat');

    //发布者权限
    Route::group(['middleware' => 'publisher.auth'], function () {
        //region 信息管理
        //信息管理列表
        Route::get('/publisher/item', 'PublisherItemController@index');
        //发布信息时需要初始化的配置
        Route::get('/publisher/item/config', 'PublisherItemController@config');
        //获取信息
        Route::get('/publisher/item/{id}', 'PublisherItemController@show');
        //发布信息
        Route::post('/publisher/item', 'PublisherItemController@store');
        //修改信息
        Route::put('/publisher/item/{id}', 'PublisherItemController@update');
        //提前结束信息
        Route::put('/publisher/item/{id}/finish', 'PublisherItemController@finish');

        //endregion

        //region 项目管理
        //获取信息
        Route::get('/publisher/project/{id}', 'PublisherProjectController@show');
        //发布信息
        Route::post('/publisher/project', 'PublisherProjectController@store');
        //修改信息
        Route::put('/publisher/project/{id}', 'PublisherProjectController@update');
        //endregion

        //region 公司管理
        //获取信息
        Route::get('/publisher/company/{id}', 'PublisherCompanyController@show');
        //发布信息
        Route::post('/publisher/company', 'PublisherCompanyController@store');
        //修改信息
        Route::put('/publisher/company/{id}', 'PublisherCompanyController@update');
        //endregion

        //新增tag
        Route::post('/item/tag', 'TagController@storeItemTag');

        //发布者订单列表
        Route::get('/publisher/order', 'PublisherOrderController@index');
        //发布者订单详情
        Route::get('/publisher/order/{id}', 'PublisherOrderController@show');
    });
});

//match cors options request
Route::options('/{one?}/{two?}/{three?}/{four?}/{five?}', function () {
    return '';
});
